package com.marketing.tenant.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.validation.constraints.Min;
import javax.validation.constraints.DecimalMin;
import java.time.LocalDateTime;
import java.math.BigDecimal;
import java.util.Objects;

/**
 * 订阅计划实体类
 * 对应数据库表：saas_subscription_plan
 */
@TableName("saas_subscription_plan")
@Schema(name = "SubscriptionPlan", description = "订阅计划信息")
public class SubscriptionPlan {

    /**
     * 计划ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "计划ID", example = "1")
    private Long id;

    /**
     * 计划编码
     */
    @NotBlank(message = "计划编码不能为空")
    @Size(max = 50, message = "计划编码长度不能超过50个字符")
    @TableField("plan_code")
    private String planCode;

    /**
     * 计划名称
     */
    @NotBlank(message = "计划名称不能为空")
    @Size(max = 100, message = "计划名称长度不能超过100个字符")
    @TableField("plan_name")
    private String planName;

    /**
     * 计划类型：TRIAL-试用，STANDARD-标准，PREMIUM-高级，ENTERPRISE-企业
     */
    @Size(max = 20, message = "计划类型长度不能超过20个字符")
    @TableField("plan_type")
    private String planType = "STANDARD";

    /**
     * 价格
     */
    @DecimalMin(value = "0.00", message = "价格不能为负数")
    private BigDecimal price = BigDecimal.ZERO;

    /**
     * 货币
     */
    @Size(max = 10, message = "货币长度不能超过10个字符")
    private String currency = "CNY";

    /**
     * 计费周期：DAILY-日付，WEEKLY-周付，MONTHLY-月付，YEARLY-年付
     */
    @Size(max = 20, message = "计费周期长度不能超过20个字符")
    @TableField("billing_cycle")
    private String billingCycle = "MONTHLY";

    /**
     * 最大用户数
     */
    @Min(value = 0, message = "最大用户数不能为负数")
    @TableField("max_users")
    private Integer maxUsers = 10;

    /**
     * 最大存储空间(字节)
     */
    @Min(value = 0, message = "最大存储空间不能为负数")
    @TableField("max_storage")
    private Long maxStorage = 1073741824L;

    /**
     * 功能特性列表(JSON格式)
     */
    private String features;

    /**
     * 计划描述
     */
    private String description;

    /**
     * 状态：1-启用，0-禁用
     */
    private Integer status = 1;

    /**
     * 软删除标记：0-未删除，1-已删除
     */
    @TableLogic
    private Integer deleted = 0;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    
    // 手动添加getter和setter方法
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getPlanCode() {
        return planCode;
    }
    
    public void setPlanCode(String planCode) {
        this.planCode = planCode;
    }
    
    public String getPlanName() {
        return planName;
    }
    
    public void setPlanName(String planName) {
        this.planName = planName;
    }
    
    public String getPlanType() {
        return planType;
    }
    
    public void setPlanType(String planType) {
        this.planType = planType;
    }
    
    public BigDecimal getPrice() {
        return price;
    }
    
    public void setPrice(BigDecimal price) {
        this.price = price;
    }
    
    public String getCurrency() {
        return currency;
    }
    
    public void setCurrency(String currency) {
        this.currency = currency;
    }
    
    public String getBillingCycle() {
        return billingCycle;
    }
    
    public void setBillingCycle(String billingCycle) {
        this.billingCycle = billingCycle;
    }
    
    public Integer getMaxUsers() {
        return maxUsers;
    }
    
    public void setMaxUsers(Integer maxUsers) {
        this.maxUsers = maxUsers;
    }
    
    public Long getMaxStorage() {
        return maxStorage;
    }
    
    public void setMaxStorage(Long maxStorage) {
        this.maxStorage = maxStorage;
    }
    
    public String getFeatures() {
        return features;
    }
    
    public void setFeatures(String features) {
        this.features = features;
    }
    
    public String getDescription() {
        return description;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public Integer getStatus() {
        return status;
    }
    
    public void setStatus(Integer status) {
        this.status = status;
    }
    
    public Integer getDeleted() {
        return deleted;
    }
    
    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }
    
    public LocalDateTime getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
    
    public LocalDateTime getUpdateTime() {
        return updateTime;
    }
    
    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SubscriptionPlan that = (SubscriptionPlan) o;
        return Objects.equals(id, that.id) &&
                Objects.equals(planCode, that.planCode) &&
                Objects.equals(planName, that.planName) &&
                Objects.equals(planType, that.planType) &&
                Objects.equals(price, that.price) &&
                Objects.equals(currency, that.currency) &&
                Objects.equals(billingCycle, that.billingCycle) &&
                Objects.equals(maxUsers, that.maxUsers) &&
                Objects.equals(maxStorage, that.maxStorage) &&
                Objects.equals(features, that.features) &&
                Objects.equals(description, that.description) &&
                Objects.equals(status, that.status) &&
                Objects.equals(deleted, that.deleted) &&
                Objects.equals(createTime, that.createTime) &&
                Objects.equals(updateTime, that.updateTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, planCode, planName, planType, price, currency, billingCycle, maxUsers, maxStorage, features, description, status, deleted, createTime, updateTime);
    }

    @Override
    public String toString() {
        return "SubscriptionPlan{" +
                "id=" + id +
                ", planCode='" + planCode + '\'' +
                ", planName='" + planName + '\'' +
                ", planType='" + planType + '\'' +
                ", price=" + price +
                ", currency='" + currency + '\'' +
                ", billingCycle='" + billingCycle + '\'' +
                ", maxUsers=" + maxUsers +
                ", maxStorage=" + maxStorage +
                ", features='" + features + '\'' +
                ", description='" + description + '\'' +
                ", status=" + status +
                ", deleted=" + deleted +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}